//
//  AddmyProjectController.m
//  Ten
//
//  Created by anfuer on 2018/11/3.
//  Copyright © 2018年 xg韦. All rights reserved.
//

#import "AddmyProjectController.h"
#import "HooDatePicker.h"
@interface AddmyProjectController ()<HooDatePickerDelegate>
@property (weak, nonatomic) IBOutlet UITextField *tsf1;
@property (weak, nonatomic) IBOutlet UITextView *tsview;
@property (weak, nonatomic) IBOutlet UIButton *btn1o;
@property (weak, nonatomic) IBOutlet UIButton *btn2o;
@property (nonatomic, strong) HooDatePicker *datePicker;
@end

@implementation AddmyProjectController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.datePicker = [[HooDatePicker alloc] initWithSuperView:self.view];
    self.datePicker.delegate = self;
    self.datePicker.datePickerMode = HooDatePickerModeDate;
    NSDateFormatter *dateFormatter = [NSDate shareDateFormatter];
    [dateFormatter setDateFormat:kDateFormatYYYYMMDD];
    NSDate *maxDate = [NSDate date];
    NSDate *minDate = [dateFormatter dateFromString:@"1960-01-01"];
    [self.datePicker setDate:[NSDate date] animated:YES];
    self.datePicker.minimumDate = minDate;
    self.datePicker.maximumDate = maxDate;
    // Do any additional setup after loading the view.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/
- (IBAction)ChosesBtna:(UIButton *)sender {
    self.datePicker.tag=sender.tag;
    
     [self.datePicker show];
    
}
- (IBAction)savaBtna:(UIButton *)sender {
     if ([FuncPublic TextFieldisError:_tsf1]) {
         if ([[_btn1o currentTitle]containsString:@"请选择"]||[[_btn2o currentTitle]containsString:@"请选择"]) {
             [WSProgressHUD showImage:nil status:@"请完善相关数据,再提交"];
             return;
         }
         //        resume_id（简历id）
         //        id（可选，工作经历 的id，不传为新增，传则为编辑）
         NSMutableDictionary*mdic=[NSMutableDictionary dictionary];
         [mdic setObject:_tsf1.text forKey:@"project_name"];
         [mdic setObject:_tsview.text forKey:@"project_description"];
         [mdic setObject:[_btn1o currentTitle] forKey:@"start_time"];
         [mdic setObject:[_btn2o currentTitle] forKey:@"end_time"];
         [mdic setObject:_resume_id forKey:@"resume_id"];
         
         [FuncPublic getData:self parameters:mdic RequestUrl:edit_projects success:^(NSDictionary *acountInfo) {
             [WSProgressHUD showImage:nil status:acountInfo[@"msg"]];
             
         }];
         
     }
  
}
- (IBAction)back:(UIButton *)sender {
    UIViewController *viewCtl = self.navigationController.viewControllers[1];
    [self.navigationController popToViewController:viewCtl animated:YES];
}
- (void)datePicker:(HooDatePicker *)datePicker didSelectedDate:(NSDate*)date {
    NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
    //    [dateFormatter setLocale:[NSLocale currentLocale]];
    [dateFormatter setDateFormat:@"yyyy-MM-dd"];
    NSString *value = [dateFormatter stringFromDate:date];
    if (datePicker.tag==1) {
          [_btn1o setTitle:value forState:UIControlStateNormal];
    }else
    {
           [_btn2o setTitle:value forState:UIControlStateNormal];
    }
  
    
}

@end
